/**
 * @(#) Dao.java
 */

package com.jomoo.css.common.core.dao;

import com.jomoo.css.common.core.support.DaoPage;
import org.hibernate.criterion.DetachedCriteria;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;

// TODO: 2016/8/10 完成后重构idao名称
public interface IDao<T> {
    public static final String BEAN_ID_SIMPLE = "baseDaoSimple";
    public static final String BEAN_ID_BASE = "baseDao";

    public List find(String queryString);

    /**
     * @param entity
     */
    void save(Object entity);

    /**
     * @param entities
     */
    void saveAll(Collection entities);
    boolean saveBatch(Collection<T> entityList, int batchSize);
    void remove(Object entity);

    /**
     * @param entities
     */
    void removeAll(Collection entities);

    void removeById(Class clazz, Serializable id);
    void removeByIds(Class clazz, Collection<Serializable> ids);

    void removeDirectly(Object entity);

    /**
     * @param entities
     */
    void removeAllDirectly(Collection entities);

    void removeByIdDirectly(Class clazz, Serializable id);

    void update(Object entity);

    public void update(Object entity, Boolean isSaveNull);

    /**
     * @param entities
     */
    void updateAll(Collection entities);

    void updateAll(Collection entities, Boolean isSaveNull);

    public void saveOrUpdate(Object entity);

    public void saveOrUpdateAll(final Collection entities);

    /**
     * @param datasetMap
     */
    void batchExecute(Map datasetMap);

    public void excuteProduce(final String sql, final String[] values);

    public Integer executeProduce(final String sql, final Map values);

    public Integer executeHqlProduce(String sql, Map values);

	<X, ID extends Serializable> X get(Class<X> domainClass, ID id);

	<X, ID extends Serializable> X load(Class<X> domainClass, ID id);

    List selectBatchIds(Class clazz, Collection ids);

    DaoPage pageBy(final DetachedCriteria detachedCriteria, final int pageIndex, final int pageSize);

    DaoPage pageBy(StringBuilder hql, Map<String, Object> params, Integer pageIndex, Integer pageSize);

    List findBy(final DetachedCriteria criteria);

    List findBy(StringBuilder hql, Map params, Integer pageIndex, Integer pageSize);

    List findBy(StringBuilder hql, Map params);

    public boolean isUnique(final Object entity, final String[] propertyNames);

    Long countBy(StringBuilder hql, Map params);

    public int queryForInt(String hql, Map<String, Object> parameterMap);

    public Date getDatabaseServerDate();
}
